package com.mrzhou.system.feign;

import com.mrzhou.common.feign.client.ISystemClient;
import com.mrzhou.core.tool.api.R;
import com.mrzhou.core.tool.constants.CloudConstant;
import com.mrzhou.system.service.IRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
public class SystemClient implements ISystemClient {

    @Autowired
    private IRoleService roleService;
    @Autowired
    private HttpServletRequest request;

    @Override
    @PostMapping(ROLE_ALIASES)
    public R<List<String>> getRoleAlias(String roleIds) {
        return R.data(roleService.getRoleAlias(roleIds));
    }

    @Override
    @PostMapping(ROLE_PERMS)
    public R<List<String>> getRolePerms(String roleIds) {
        return R.data(roleService.getRolePerms(roleIds));
    }

    @Override
    @PostMapping("boolean")
    public Boolean tempBoolean() {
        System.out.println(request.getHeader(CloudConstant.HEADER_CLOUD_ID));
        return false;
    }

}
